﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Dev_house_Project.ViewModel.DataService;
using Visifire.Charts;


namespace Dev_house_Project.ViewModel.Converters
{
    public class CompaniesToChartDataSeries : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is List<Company>)) return null;

            var list = (List<Company>)value;
            var dataSeries = new DataSeries();

            foreach (var company in list)
            {
                var dataPoint = new DataPoint();

                dataPoint.AxisXLabel = company.CompanyName;
                dataPoint.YValue = company.Count;

               dataSeries.DataPoints.Add(dataPoint);
            }

            return dataSeries;
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}